Function Reference

_GUICtrlEditSetSel

Selects a range of characters in an edit control.

#Include <GuiEdit.au3>
_GUICtrlEditSetSel($h_edit, $i_start, $i_end)

 

Parameters

$h_edit control id/control hWnd
$i_start Specifies the starting character position of the selection.
$i_end Specifies the ending character position of the selection.

 

Return Value

None.

 

Remarks

The start value can be greater than the end value.
The lower of the two values specifies the character position of the first character in the selection.
The higher value specifies the position of the first character beyond the selection.

The start value is the anchor point of the selection, and the end value is the active end.
If the user uses the SHIFT key to adjust the size of the selection, the active end can move but the anchor point remains the same.

If the $i_start is 0 and the $i_end is û1, all the text in the edit control is selected.
If the $i_start is û1, any current selection is deselected.

The control displays a flashing caret at the $i_end position regardless of the relative values of $i_start and $i_end.

 

Related

_GUICtrlEditGetSel

 

Example


#include <GUIConstants.au3>
#include <GuiEdit.au3>

opt('MustDeclareVars', 1)

Dim $myedit, $msg

GUICreate("Edit Set Sel", 392, 254)

$myedit = GUICtrlCreateEdit("AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI." & @CRLF, 140, 32, 121, 97, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE, $WS_HSCROLL))
GUICtrlSetLimit($myedit, 1500)

; will be append dont' forget 3rd parameter
GUICtrlSetData($myedit, "It uses a combination of simulated keystrokes, mouse movement and window/control manipulation" & @CRLF & _
      "in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript" & @CRLF & _
      "and SendKeys)." & @CRLF & _
      'AutoIt was initially designed for PC "roll out" situations to configure thousands of PCs, but with the' & @CRLF & _
      "arrival of v3 it is also well suited to performing home automation and the scripting of repetitive" & @CRLF & _
      "tasks." & @CRLF & @CRLF & "AutoIt can:" & @CRLF & @CRLF & "Execute Windows and DOS executables", 1)

GUISetState()
_GUICtrlEditSetSel ($myedit, 0, 6)

; Run the GUI until the dialog is closed
While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE
         ExitLoop
   EndSelect
WEnd